var app = require('../app'),
    formMod = require('../../modules/form'),
    template = require('../../modules/template'),
    lockfas = false;
var winHeight = $(window).height() -310,
winHeight2 = $(window).height() -270;
$(".with-window").css("height",winHeight);
$(".with-window2").css("height",winHeight2); 
$(window).resize(function() { 
    winHeight = $(window).height() -310;
    winHeight2 = $(window).height() -270;
    $(".with-window").css("height",winHeight);
    $(".with-window2").css("height",winHeight2); 
});
$('.page-top-left-btn').on('click',function(){
    $(this).addClass('left-btn-checked').siblings().removeClass("left-btn-checked");
    $('.box-main4,.box-main3,.context-box-main,.box-main5').css('display','none')
    if($(this).attr('type') == "1"){
        $('.box-main1').css('display','block')
    }else if($(this).attr('type') == "3"){
        $('.box-main2').css('display','block')
    }else if($(this).attr('type') == "2"){
        $('.box-main3').css('display','flex')
    }else if($(this).attr('type') == "4"){
        $('.box-main4').css('display','flex')
    }else if($(this).attr('type') == "5"){
        $('.box-main5').css('display','block')
    }
})

var  defaultFileSrc = $('.caseCheckInfo-main-nav-li').eq(0).attr('filepath')
$('.showFile').attr('src',defaultFileSrc);
$('.caseCheckInfo-main-nav-li').on('click',function(){
    var fileSrc = $(this).attr('filepath')
    $('.showFile').attr('src',fileSrc)
    $('.caseCheckInfo-main-nav-li-img-box').removeClass('caseCheckInfo-main-nav-li-img-box-checked');
    $('.caseCheckInfo-main-nav-li-name').removeClass('caseCheckInfo-main-nav-li-name-checked');
    $(this).children(".caseCheckInfo-main-nav-li-img-box").addClass('caseCheckInfo-main-nav-li-img-box-checked');
    $(this).children(".caseCheckInfo-main-nav-li-name").addClass('caseCheckInfo-main-nav-li-name-checked');
})
$('.page-top-right-btn').on('click',function(){
    $(this).addClass('left-btn-checked');
    window.history.back(-1);
})
$('.ui-audio').each(function(){
    var that = $(this);
    that.get(0).onloadedmetadata = function(){
        that.removeClass('none');
        that.parent().find('.context-box-main-min-time2').removeClass('none');
    }
})
$('.changeBtn').on('click',function(){
    var valid_call = $(this).attr('data-valid_call');
    var desc = $(this).attr('data-desc');
    var log_id = $(this).attr('data-log_id');
    console.log(valid_call)
    console.log(desc);
    $('[role-ele=modal]').html(template.render('modelTpl',{valid_call:valid_call,desc:desc,log_id:log_id}));
    $('#exampleModal').modal();
})
formMod.listen('/caseinfo/updateMediateLog',{
    ajaxBefore: function(validResutl){
    },
    validError: function(validResutl){
        var item  = validResutl.element;
        if(item.attr('name')=='desc'){
            if(validResutl.valid == 'notempty'){
                toastr.info('请填写备注信息');
            }
        }
    },
    cleanup: function(item){},
    success: function(result){
        var res = result.data;
        if(res.code == 200){
            toastr.success('提交成功');
            setTimeout(function(){
                window.location.reload();
            },3000);
        }else{
            toastr.error(res.message);
           
        }

    },
    error: function(){}
});